package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsCouponMapper;
import com.qf.pojo.DtsCoupon;
import com.qf.service.DtsCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Zwnan
 */
@Service
public class DtsCouponServiceImpl implements DtsCouponService {

    @Autowired
    private DtsCouponMapper dtsCouponMapper;

    @Override
    public IPage<DtsCoupon> findPage(Integer page, Integer limit, String sort, String order) {
        IPage<DtsCoupon> iPage = new Page<>();

        return dtsCouponMapper.selectPage(iPage,new QueryWrapper<DtsCoupon>().eq("deleted", false));
    }

    @Override
    public DtsCoupon findById(String id) {
        return dtsCouponMapper.selectById(id);
    }

    @Override
    public void insert(DtsCoupon dtsCoupon) {
        dtsCouponMapper.insert(dtsCoupon);
    }

    @Override
    public void update(DtsCoupon dtsCoupon) {
        dtsCouponMapper.updateById(dtsCoupon);
    }

    @Override
    public void delete(DtsCoupon dtsCoupon) {
        dtsCoupon.setDeleted(true);
        dtsCouponMapper.updateById(dtsCoupon);
    }
}
